package day9.homework;

public
class Demo4 implements Runnable {
    int id;
    static int i;
    static int len;
    public Demo4(int id) {
        this.id = id;
    }
    @Override
    public
    void run() {
        String name = Thread.currentThread().getName();
        while (i<3*5) {
            synchronized (Demo4.class) {
                if (i % len == id) {
                    System.out.print(name);
                    i++;
                    Demo4.class.notifyAll();
                }
                try {
                    Demo4.class.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public static
    void main(String[] args) {
        len=3;
        for (int i=0;i<len;i++){
            new Thread(new Demo4(i),(char)(65+i)+"").start();
        }
    }
}